<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="com.saturn.auth.User"%>
<%@page import="com.saturn.sldb.Discussion"%>
<%@page import="com.saturn.app.utils.DateUtils"%>
<%@page import="com.saturn.auth.Organization"%>
<%@page import="java.util.*"%>
	<%
	User user = (User)session.getAttribute("authUser");
	String userId = user.getId();
	Organization organizationUser = Organization.getOneOrganizationByUser(userId);
	String name = organizationUser.getName();
	List organizations = Organization.getOrganizationByUser(user.getId());
	String department = "";
	if (organizations != null && !organizations.isEmpty()) {
		department = ((Organization)organizations.get(0)).getName();
	}
	%>	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加紧急救助低保</title>
<%@ include file="/app/includes/header.jsp"%>
<style type="text/css">
<!--
.STYLE1 {
	font-size: 24px;
	font-weight: bold;
}
-->
	input {border:none;}
	.table_1{border-right:1px solid black; border-top:1px solid black}
	.table_1 td{border-left:1px solid black; border-bottom:1px solid black;}
	body{font-size:12px;}
</style>
<script> 
function submit(){ 
if(addForm.name.value==""){ 
alert("请输入姓名"); 
}else if(addForm.sex.value==""){ 
alert("请输入性别"); 
}else if(addForm.identify.value==""){ 
alert("请输入身份证号"); 
}else if(addForm.home.value==""){ 
alert("请输入家庭人口"); 
}else{
	var identify = $("#identify").val();
	//*********家庭编号根据低保对象表中获取存储到数据库中*********BEGIN
	$.ajax({
		type : 'post',
		async : false,
		data : { "identify": identify},
		url : "<%=request.getContextPath()%>/app/sldb/emergency/apply/checkHomeNumberAction.action",
		success : function(data, textStatus, jqXHR){
			//console.info(data);
			if(data.homeNumber!=null){
				$("#homeNumber").val(data.homeNumber);
			}
		},
		dataType : 'json'
	});
	//*********家庭编号根据低保对象表中获取存储到数据库中*********END

	//*******************如不存在则返回“此申报信息为非低保户“信息字样******BEGIN
	var safeWay = $("input[name='safeWay']:checked").val();
	if(safeWay=="低保对象"){
		if(identify==""||identify==null){
			alert("身份证号不能为空");
			return;
		}
		$.post(
			"<%=request.getContextPath()%>/app/sldb/emergency/apply/checkSafeWayAction.action",
			{ "identify": identify},
			function(data){
				if(data.count==0){
					alert("此申报信息为非低保户");
					return;
				}else{
					$('#addForm').submit();
				}
			}, 
			"json");
	}else{
		$('#addForm').submit();
	}
	//*******************如不存在则返回“此申报信息为非低保户“信息字样******END
	
	}
} 
</script> 

<% 
	Calendar ca = Calendar.getInstance();
	int year = ca.get(Calendar.YEAR); //获取年份
	Discussion discussion = new Discussion();
	User user1 = (User)request.getSession().getAttribute("authUser");// TODO Auto-generated method stub
	String number = user1.getNumber();
	String id = user1.getId();
	number = number.substring(number.length()-4,number.length()-2);
	String numNO = "";
	String num1="";
	Discussion discussion1 = Discussion.getByCreater(id);
	if("".equals(discussion1) || discussion1 == null ){
		num1 = "001";
	}else{
		numNO = discussion1.getNumberNO();
		String numNOStr = numNO.substring(numNO.length()-3, numNO.length());
	    int a = Integer.valueOf(numNOStr);
	    int i = ++a;
	    int len = new Integer(a).toString().length();
	    switch (len) {
	    case 1:
	    	num1="000"+i;
	        break;
	    case 2:
	    	num1="00"+i;
	        break;
	    default:
	    	num1=i+"";
	        break;
	    }
	}
	
	String lnumberNO = "L"+ year + number + num1;
%>
</head>
<body>
	<form id="addForm" name="addForm" action="<%=request.getContextPath()%>/app/sldb/discussion/apply/addDiscussion.action" method="post">
			<input id="createTime" name="createTime" type="hidden" value="<%=DateUtils.getSystemTime()%>"></input>
			<input id="creater" name="creater" type="hidden" value="<%=user.getId()%>"></input>
			<input id="createrName" name="createrName" type="hidden" value="<%=user.getName()%>"></input>
			<input id="createrDepartment" name="createrDepartment"  type="hidden" value="<%=department%>"></input>
			<input id="state" name="state" type="hidden" value="创建"></input>
			<input id="homeNumber" name="homeNumber" type="hidden" value=""></input>
			<input id="files" name="files" type="hidden" value=""></input>
			<input id="inputType" name="inputType" type="hidden" value="自动"></input>
			<input id="subject" name="subject" type="hidden" value=""></input>
			<input id="remarks" name="remarks" type="hidden" value="暂无数据"></input>
			<input id="type" name="type" type="hidden" value="一事一议"></input>
			
		<OBJECT classid="clsid:10946843-7507-44FE-ACE8-2B3483D179B7"
			id="CVR_IDCard" name="CVR_IDCard" width="0" height="0"> </OBJECT>

		<script language="javascript" type="text/javascript">
				 function ClearForm() {
					document.getElementById('name').value = "";
                    document.getElementById('sex').value = "";
                    document.getElementById('identify').value =  "";
                    document.getElementById('picture').src = ""; 
                      ClearForm2();
                      return true;
				} 
				function ClearForm2() {
					var i=0;
					for(;i<6;i++){
						document.getElementById('c_name'+i).value = "";
	                    document.getElementById('c_sex'+i).value = "";
	                    document.getElementById('c_identify'+i).value = "";
	                    document.getElementById('c_relation'+i).value = "";
					}
					
                      return true;
				} 
				function Button1_onclick() {
                   	var CVR_IDCard = document.getElementById("CVR_IDCard");	
					var strReadResult = CVR_IDCard.ReadCard();
					if(strReadResult == "0")
					{
						//ClearForm();
                        document.getElementById('name').value =  CVR_IDCard.Name;
                        document.getElementById('sex').value =  CVR_IDCard.Sex;
                        document.getElementById('identify').value =  CVR_IDCard.CardNo;
                        document.getElementById('picture').src = "data:image/jpg;base64,"+CVR_IDCard.Picture;
                        document.getElementById('photo').value = CVR_IDCard.Picture;
                      	//当前申请人员保障信息统计
                        window.open ('<%=request.getContextPath()%>/app/sldb/discussion/apply/statistics.jsp?cardNo='+CVR_IDCard.CardNo,'打印页面','height=300,width=300,top=50,left=300,toolbar=no,menubar=no,scrollbars=yes, resizable=no,location=no, status=no');
                   }else{
                        ClearForm();
                        alert(strReadResult);
                   }
				}
		</script>
		<a href="#" onclick="Button1_onclick()" class="easyui-linkbutton" id="Button1">户   主</a>
		<a href="#" onclick="submit()" class="easyui-linkbutton" id="Button1">提   交</a>
		<a href="#" onclick="ClearForm()" class="easyui-linkbutton" id="Button2">清   空</a>
		<p>
<center>
<label style="font-size:24px">临时救助“一事一议”事项流程单</label>
<br> 
<br>
<table width="60%" border="0" align="center" cellpadding="0" cellspacing="0" class="table_1">
  <tr>
      <td height="30" colspan="7" align="right">
    	编号： <input type="text" id="numberNO" name="numberNO" value="<%=lnumberNO %>" style="border-top-style:none;border-left-style:none;border-right-style:none;border-bottom-style:none;"/>
    	<input id="ynumberNO" type="hidden" value="<%=lnumberNO %>" />
    </td>
  </tr>
  <tr>
    <td height="20" colspan="7" bgcolor="#BFBFBF"><strong>申请人基本情况：</strong></td>
    </tr>
  <tr>
    <td width="104" height="37"><div align="center">户主或本人姓名</div></td>
    <td width="116"><input id="name" type="text" name="name" size="9" readonly="readonly"/></td>
    <td width="111"><div align="center">性别</div></td>
    <td width="73"><input id="sex" type="text" name="sex" size="9" readonly="readonly"/></td>
    <td width="69"><div align="center">家庭人口</div></td>
    <td width="66"><input id="home" type="text" name="home" size="9"/></td>
    <td rowspan="3"><img src="" style="width: 80px; height: 90px" id="picture" name="picture" /></td>
    </tr>
  <tr>
    <td height="33"><div align="center">
      <p>公民身份证号</p>
      </div></td>
    <td colspan="5" align="left"><input id="identify" type="text" name="identify" size="18"  readonly="readonly"/></td>
    </tr>
  
  <tr>
    <td height="50"><div align="center">对象类别</div></td>
    <td colspan="5" align="left">
      <span class="STYLE2"><input type="radio" name="peopleType" checked="checked" value="个人对象" />个人对象&nbsp;&nbsp;<input type="radio" name="registration" checked="checked" value="本地户籍" />本地户籍&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="accountType" checked="checked" value="农村居民" />农村居民&nbsp;&nbsp;<input id="safeWay" type="radio" name="safeWay" checked="checked" value="低保对象" />低保对象</span><br>
      <span class="STYLE2"><input type="radio" name="peopleType" value="家庭对象" />家庭对象&nbsp;&nbsp;<input type="radio" name="registration" value="非本地户籍" />非本地户籍 &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="accountType" value="城市居民" />城市居民&nbsp;&nbsp;<input type="radio" name="safeWay" value="非低保对象" />非低保对象</span></td>
    </tr>
 
  <tr>
    <td height="55"><div align="center">申请事由</div></td>
    <td height="55" colspan="6" align="left"><span class="STYLE2"><input type="radio" name="applyCause" checked="checked" value="火灾" />火灾&nbsp;<input type="radio" name="applyCause" value="交通事故" />交通事故&nbsp;<input type="radio" name="applyCause"  value="突发重大疾病" />突发重大疾病<input type="radio" name="applyCause" value="困境低保" />困境低保&nbsp;<input type="radio" name="applyCause" value="支出型困难" />支出型困难&nbsp;<input type="radio" name="applyCause" value="其他特殊困难" />其他特殊困难</span><br><br>&nbsp;病种描述：<input type="text" name="causeDesc" id="causeDesc" size="60" style="border-bottom: 1px solid;"/></td>
  </tr>
  
  <tr>
    <td height="100"><div align="center">启动“一事
    	<br>一议”理由</div></td>
    <td height="100" colspan="6" align="left"><textarea id="startCause" name="startCause" style="height:80px; width:500px;border:none;"></textarea>
    </td>
  </tr>
   <tr>
    <td height="28"><div align="center">审批人</div></td>
    <td colspan="2" align="left"><input id="audit" type="text" name="audit" size="11" /></td>
    <td colspan="3"><div align="center">审批金额</div></td>
    <td align="left"><input id="money" type="text" name="money" size="11" /></td>
  </tr>
  <tr>
    <td height="20" colspan="7" bgcolor="#BFBFBF" align="left"><strong>附件：</strong></td>
    </tr>
  <tr>
    <td height="99" colspan="7" align="left">&nbsp;&nbsp;&nbsp;&nbsp;暂无附件</td>
    </tr>
</table>
</center>
<input type="hidden" id="photo" name="photo" value="暂无照片"/>
</form>
 <script type="text/javascript">
	$(document).ready(function() {
		$("#identify").blur(function(){
			var identify = $("#identify").val();
			var length = identify.length;
			if(length!=18 && length!=15){
				alert("身份证号位数为15位或18位！");
				return;
			}
			if(identify==""||identify==null){
				alert("身份证号不能为空");
				return;
			}
			//当前申请人员保障信息统计
            window.open ('<%=request.getContextPath()%>/app/sldb/discussion/apply/statistics.jsp?cardNo='+identify,'打印页面','height=300,width=900,top=50,left=300,toolbar=no,menubar=no,scrollbars=yes, resizable=no,location=no, status=no');
		});
	});
		//*******************模态窗口形式统计当前低保户本年的申报次数、总金额、年份、姓名、身份证号信息******END
</script>
</body>
</html>
